<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="img/favicon.html">

    <title>Profile Edit</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet"/>
    <!-- Custom styles for this template -->
    <link href="css/style.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet"/>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<section id="container" class="">
    <!--header start-->
    <div id="header">

    </div>
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">
            <!-- page start-->
            <div class="row">
                <aside class="profile-nav col-lg-3">
                    <section class="panel">
                        <div class="user-heading round">
                            <a href="#">
                                <img :src='"http://1.116.220.143:9999/"+user.img' alt="" id="imgs">
                            </a>
                            <div style="position: relative;">
                                <form enctype="multipart/form-data" method="post" id="imgForm">
                                    <button style="width: 100px;height: 30px;background-color: #41cac0;color: white;border: none;border-radius: 10px;">
                                        更换图片
                                    </button>
                                    <input type="file" id="file" name="file" accept="image/*"
                                           style="position: absolute;left: 0;top: 0;opacity: 0;" @change="updateImg($event)">
                                </form>
                            </div>
                            <h1>{{user.userName}}</h1>
                        </div>

                        <ul class="nav nav-pills nav-stacked">
                            <li><a href="userInfo.html"> <i class="icon-user"></i> 基本信息</a></li>
                            <li><a href="userInfoModify.html"> <i class="icon-calendar"></i> 修改信息</a></li>
                            <li class="active"><a href="userPwdModify.html"> <i class="icon-edit"></i>密码修改</a></li>
                            <li><a href="userInfoPaiban.html"> <i class="icon-edit"></i>查看本月排班</a></li>

                        </ul>

                    </section>
                </aside>
                <aside class="profile-info col-lg-9">
                    <section>
                        <div class="panel panel-primary">
                            <div class="panel-heading"> 修改密码</div>
                            <div class="panel-body">
                                <form class="form-horizontal" role="form" id="myForm">
                                    <div class="form-group">
                                        <label class="col-lg-2 control-label">原密码</label>
                                        <div class="col-lg-6">
                                            <input type="password" class="form-control" id="c-pwd" v-model="oldPassword" @change="pwd">
                                        </div>
                                        <div class="error" style="color: red;font-size: 17px;"></div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-lg-2 control-label">新密码</label>
                                        <div class="col-lg-6">
                                            <input type="password" class="form-control" id="n-pwd" v-model="password" name="password"
                                                   datatype="*6-15" errormsg="密码范围在6~15位之间！">
                                        </div>
                                        <div class="Validform_checktip" style="color: red;font-size: 17px;"></div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-lg-2 control-label">确认密码</label>
                                        <div class="col-lg-6">
                                            <input type="password" class="form-control" id="rt-pwd" v-model="affirm"
                                                   datatype="*" recheck="password" errormsg="您两次输入的账号密码不一致！">
                                        </div>
                                        <div class="Validform_checktip" style="color: red;font-size: 17px;"></div>
                                    </div>

                                    <div class="form-group">
                                        <div class="col-lg-offset-2 col-lg-10">
                                            <button type="button" class="btn btn-info qr">确认修改</button>
                                            <button type="button" class="btn btn-default fh" onclick="javascript:history.back()">返回</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>

            <!-- page end-->
        </section>
    </section>
    <!--main content end-->
</section>

<!-- js placed at the end of the document so the pages load faster -->
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.scrollTo.min.js"></script>
<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
<script src="js/axios.js"></script>
<script src="js/Validform_v5.3.2_min.js"></script>
<script src="localjs/userinfo.js"></script>
<script src="js/jquery.nicescroll.js" type="text/javascript"></script>
<script src="assets/jquery-knob/js/jquery.knob.js"></script>

<!--common script for all pages-->
<script src="js/common-scripts.js"></script>
<script>
    $(function () {
        $("#myForm").Validform({
            btnSubmit: ".qr",
            tiptype: 4,
            callback: function() {
                let data=new URLSearchParams();
                data.append("password",app.password);
                data.append("id",app.user.id);
                axios({
                    url:"yly-api/admin/updatePwd",
                    data:data,
                    headers:{"token":localStorage.token,"url":window.location.pathname},
                    method: "post"
                }).then(function (res) {
                    console.log(res);
                    if (res.data.code==200){
                        if (res.data.data==true){
                            alert("修改成功,请重新登录！");
                            localStorage.token=null;
                            location.href="login.html";
                        }else {
                            alert("修改失败,请联系管理员！");
                        }
                    }else if (res.data.code==500){
                        location.href="500.html";
                    }
                }).catch(function (error) {
                    console.log(error.response.status);
                    if (error.response.status==401){
                        alert("权限不足，无法访问!");
                        location.href="login.html";
                    }else if (error.response.status==403){
                        alert("用户已过期，请重新登录！");
                        localStorage.token=null;
                        location.href="login.html";
                    }
                });
                return false;
            }
        });
    });
</script>


</body>
</html>
